package com.hhkj.study.admin.order.controller;

import com.hhkj.study.admin.order.entity.Order;
import com.hhkj.study.admin.order.excel.OrderItemExcelRes;
import com.hhkj.study.admin.order.model.req.OrderReq;
import com.hhkj.study.admin.order.model.res.OrderRes;
import com.hhkj.study.admin.order.service.biz.OrderBizService;
import com.ruoyi.common.annotation.PermissionPrefix;
import com.ruoyi.common.base.biz.controller.v3.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.excl.ExcelImportBaseTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
* OrderController
*
* @author SERVER
* @since 2024-09-18
*/
@RestController
@PermissionPrefix("order:order")
@Controller
@RequestMapping("/admin/order")
public class OrderController extends BaseController<Order, OrderReq, OrderRes, OrderBizService> {


    /**
     * 批量导入用户订单
     * @param file
     * @param request
     * @return
     */
    @PostMapping("/user/batch/import")
    public AjaxResult importUserOrder(@RequestParam("file") MultipartFile file, HttpServletRequest request){
        return AjaxResult.success(getBizService().importUserOrder(file, request));
    }

    @Override
    public ExcelImportBaseTemplate getExcelImportBaseTemplate() {
        return new OrderItemExcelRes();
    }
}
